<?php

namespace Home\Model;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * 操作记录类
 * 
 * @author Moon
 */
use Think\Model;

class OperationRecordModel extends Model {
    /*
     * 添加一条操作记录
     */

    public function addOperationRecord($obj) {
        //$data = D('OperationRecord');
        //$data->create($obj);
        $res = $this->add($obj);

        return $res;
    }

    /*
     * 删除一条记录
     */

    public function deleteOperationRecord($obj) {
        //$data = D('OperationRecord');
        $res = $this->where('ID=' . $obj[ID])->delete();
        return $res;
    }

    /*
     * 查询记录
     * 通过员工ID
     */

    public function selectOperationRecordById($obj) {
        //$data = D('OperationRecord');
        $res = $this->where('employee_ID=' . $obj)->select();
        return $res;
    }

    /*
     * 查询记录
     * 通过时间
     */

    public function selectOperationRecordByTime($obj) {
        //$data = D('OperationRecord');
        $res = $this->where('operationTime="' . $obj . '"')->select();
        return $res;
    }

    /*
     * 通过操作类型查找
     */

    public function selectOperationRecordByType($obj) {
        //$data = D('OperationRecord');
        $res = $this->where('operationType=' . $obj)->select();
        return $res;
    }

    /*
     * 操作内容查询
     */

    public function selectOperationRecordByEvent($obj) {
        //$data = D('OperationRecord');
        $res = $this->where('operationEvent like "%' . $obj . '%"')->select();
        return $res;
    }

    /*
     * 查询所有内容
     */

    public function selectOperationRecordAll($obj) {
        //$data = D('OperationRecord');
        $res = $this->select();
        return $res;
    }

    /*
     * 修改一条记录
     */

    public function updateOperationRecord($obj) {
        //$data = D('OperationRecord');
        $res = $this->where("employee_ID='" . $obj['employee_ID'] . "' and operationTime = '" . $obj['operationTime'] . "'")->save($obj);
        return $res;
    }

}
